<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="en">
	<head>
		<!-- header -->
		<%@ include file="/WEB-INF/views/include/header.jsp"%>
	</head>
	<body class="no-skin">
	<%--上传成功模态框--%>
		<div class="shade" style="display: none;"></div>
		<div class="warning" style="display: none;">
			<p class="title"><em></em><span class="close">X</span></p>
			<p class="cont"></p>
			<div class="la-square-jelly-box la-3x">
				<div></div>
				<div></div>
			</div>
		</div>
		<!-- /section:basics/navbar.layout -->
		<div class="main-container" id="main-container">
			<script type="text/javascript">
				try{ace.settings.check('main-container' , 'fixed')}catch(e){}
			</script>

			<!-- /section:basics/sidebar -->
			<div class="main-content">
				<div class="main-content-inner">
					<div class="page-content">
						<!-- /section:settings.box -->
						<div class="row">
							<div class="col-xs-12" style="display: none">
								<div class="pull-right">
									<!-- 权限按钮拦截部分 -->
									   <%-- <button class="btn btn-sm btn-pink" id="import">导入</button>--%>
										<button class="btn btn-sm btn-info" id="query">查询</button>
										<button class="btn btn-sm btn-default" id="edit">修改</button>
										<button class="btn btn-sm btn-success" id="create">新增</button>
										<button class="btn btn-sm btn-danger" id="delete">删除</button>
									<input type="file" class="form-control" id="btn-Excel" style="display: none">
									<button class="btn btn-info btn-sm" id="displayExcel" onclick="document.getElementById('btn-Excel').click()">
										导入用户
									</button>
									<button class="btn btn-info btn-sm" onclick="alert('用户角色选择填写主要领导、分管领导、经办人');window.open('/user/downUserModle/')">
										下载用户模板
									</button>
									<!-- 权限按钮拦截部分 -->
								</div>
							</div>
						</div>
						<div class="row">
							<div class="col-xs-12">
								<!-- PAGE CONTENT BEGINS -->
									<!-- jqGrid表格 -->
									<table id="gridTable"></table>
									<!-- jqGrid工具类 -->
									<div id="gridPager"></div>
									<!-- 查询对话框 -->
									<div style="display: none;">
										<div class="row" id="queryDialog"></div>
									</div>
								<!-- PAGE CONTENT ENDS -->
							</div><!-- /.col -->
						</div><!-- /.row -->
					</div><!-- /.page-content -->
				</div>
			</div><!-- /.main-content -->

			<a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
				<i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
			</a>
			
			<!-- dialog -->
			<%@ include file="/WEB-INF/views/include/dialog.jsp"%>
		</div><!-- /.main-container -->
		
		<!-- footer -->
		<%@ include file="/WEB-INF/views/include/footer.jsp"%>
		
		<script type="text/javascript">

            /**
             * 任务状态格式化
             */
            function typeFormatter(data) {
                switch(data) {
                    case '1':
                        return '立项通知';
                        break;
                    case '2':
                        return '批转通知';
                        break;
                    case '3':
                        return '催办通知';
                        break;
                    case '4':
                        return '逾期通知';
						break;
                      case '5':
                        return '提前提醒通知';
						break;
						case '6':
							return '攻坚120任务生成通知';
							case "7":
								return '攻坚120任务逾期通知';

                    default:
                        return '未知';
                }
            }
			function stateFormatter(data) {
				switch(data) {
					case '1':
						return '成功';
						break;
					case '0':
						return '失败';
						break;

					default:
						return '未知';
				}
			}

			//基本路径
			var baseUrl = "<s:url value="/smslogs/logs"></s:url>/"
			
			//jqgrid的表格高度
			var height = 320;
			//jqgrid表格行头的中文
			var colNames = ['','内容','接收人姓名','类型','发送日期','发送时间','状态','备注'];
			//jqgrid表格中每一行的信息模型
			var colModel = [
				{name:'sysId', width:60, hidden: true,key:true},
				{name:'content',index:'content', width:250, editable: true,},
				{name:'name',index:'name', width:60, editable: true},
				{name:'type',index:'type', width:60, editable: true,formatter: typeFormatter},
				{name:'sendDate',index:'sendDate', width:60, editable: true},
				{name:'sendTime',index:'sendTime', width:60, editable: true},
				{name:'state',index:'state', width:60, editable: true,formatter:stateFormatter},
				{name:'message',index:'message', width:60, editable: true},

			];
			//jqgrid的具体执行方法
			jqgrid({
				gridTableId : "#gridTable",
				gridPagerId : "#gridPager",
				autoScroll: false,
				rownumbers: true,
				shrinkToFit: true,
				multiselect: false,
			});
			
			//加载查询对话框
			$("#queryDialog").load(getUrl("filter"));
			
			//重置表单
			function reset() {
				resetForm("#formDialog form");
			}
			
			//显示查询对话框
			var queryDialog = $("#queryDialog");
			$("#query").click(function() {
				showDialog({
					dialogTitle: '查询对话框',
					dialogBody: queryDialog,
					dialogFoot: "<button type='button' class='btn btn-primary' onclick='query()'>查询</button>" +
					"<button type='button' class='btn btn-pink' onclick='reset()'>重置</button>" +
					"<button type='button' class='btn btn-default' data-dismiss='modal'>关闭</button>"
				});
			});
			
			//具体查询方法
			function query() {
				seachJqgird("#gridTable","#formDialog form");
				$("#formDialog").modal('hide');
			}
			
			//更新操作
			$("#edit").click(function() {
				showEditDialog({
					tableId: "#gridTable",
					dialogTitle: "更新对话框",
					dialogUrl: getUrl("edit"),
					dialogFoot: '<button type="button" class="btn btn-primary" onclick="edit()">更新</button>' + 
					'<button type="button" class="btn btn-pink" onclick="reset()">重置</button>' + 
					'<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>',
					errorTitle: "消息对话框",
					errorMutiSelectMessage: '您当前选中多行，请重新选择',
					errorUnSelectMessage: '您当前尚未选中一行，请选择后再试',
					errorOk: '确定'
				});
			});
			
			//执行更新操作
			function edit() {
				executeSaveOrUpdate({
					formId: "#formDialog form",
					dialogId: "#formDialog",
					url: getUrl("edit"),
					tableId: "#gridTable",
					successMessage: "更新成功",
					successTitle: '更新对话框',
					failMessage: '更新失败',
					failTitle: '消息对话框'
				});
			}
			
			//删除
			$("#delete").click(function() {
				showDeleteDialog({
					url: getUrl("delete"),
					tableId: "#gridTable",
					confirmTitle: "确认对话框",
					confirmMessage: "是否确定删除?",
					confirmOk: "确定",
					confirmCancel: "取消",
					successMessage: "删除成功",
					successTitle: "消息对话框",
					failTitle: "消息对话框",
					errorTitle: "警告提示框",
					errorMessage: "您当前尚未选中一行，请选择后再试",
					errorOk: "确定"
				});
			});
			
			//显示创建对话框
			$("#create").click(function(){
				loadDialog({
					dialogTitle: '创建对话框',
					dialogUrl: getUrl("create"),
					dialogFoot: '<button type="button" class="btn btn-primary" onclick="create()">添加</button>' + 
					'<button type="button" class="btn btn-pink" onclick="reset()">重置</button>' + 
					'<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>'
				});
			});
			
			//保存数据
			function create() {
				executeSaveOrUpdate({
					formId: "#formDialog form",
					dialogId: "#formDialog",
					url: getUrl("create"),
					tableId: "#gridTable",
					successMessage: "保存成功",
					successTitle: '保存对话框',
					failTitle: '消息对话框'
				});
			}


			//导入excel
            /**
             *  导入Excel
             */
            $(document).on('change', "#btn-Excel",function () {
                var $this = $(this);
                var slgBtn = $(this).siblings("#displayExcel")
                var file = $(this).val();
                var formData = new FormData();
                formData.append("excelFile", $("#btn-Excel")[0].files[0]);
                $(".shade").fadeIn(100);
                $(".warning").fadeIn(100);
                $('.la-square-jelly-box').show();
                showShade();
                //警告框自定义内容
                $('.warning>.title>em').html('加载中……');
                if(file){
                    $.ajax({
                        url: "/taskMain/taskExcel",
                        data: formData,
                        type: "post",
                        processData: false,
                        contentType: false,
                        success: function(data) {
                            $('.warning>.title>em').html(data);
                            $this.remove();
                            slgBtn.before(
                                "<input type=\"file\" class=\"form-control\" id=\"btn-Excel\" style=\"display: none\">"
                            )
                        }
                    });
                }else {
                    alert("导入失败")
                }
            });
		</script>
	</body>
</html>